<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="../../static/semantis-ui/semantic.min.css">
    <script type="text/javascript" src="../../static/semantis-ui/jquery-3.6.0.js"></script>
    <script src="../../static/semantis-ui/semantic.min.js"></script>
    <!--引入的Markdown编辑器-->
    <script src="../../static/lib/editormd/editormd.min.js" th:src="@{/editormd/editormd.min.js}"></script>
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css" th:href="@{/css/editormd.min.css}">
    <link rel="stylesheet" href="../../static/css/me.css">
    <title>新增分类</title>
</head>
<body>
<!--导航-->
<!--segment反转 inverted平铺 导航栏-->
<nav class="ui segment inverted attached segment me-padded-tb-mini bg">
    <!--放在一个container中-->
    <div class="ui container ">
        <!--里面的菜单   stackable适应手机-->
        <div class="ui inverted stackable menu bg">
            <h2 class="ui teal header item ">HJ&nbsp&nbspblog</h2>
            <a href="#" th:href="@{/admin/blogs}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu icon home"></i>首页</a>
            <a href="#" th:href="@{/admin/types}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu folder open outline icon"></i>分类</a>
            <a href="#" th:href="@{/admin/tags}"  class="m-item item m-mobile-hide"><i class="m-margin-tb-menu edit outline icon"></i>标签</a>
            <div class="right menu">
                <div class="ui dropdown item" th:replace="admin/_fragments :: content">
                    <div class="text">
                        <img src="../../static/image/小.png" alt="" class="ui avatar image">
                        王锡豪
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>


                </div>
            </div>

        </div>
    </div>
    <!--三条杠 更多按钮-->
    <a href="#" class="ui icon button menu toggle m-right-top bg white-font m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" class="active teal item" th:href="@{/admin/types/input}">新增</a>
            <a href="#" class="item" th:href="@{/admin/types}">列表</a>

        </div>

    </div>
</div>


<!--中间-->
<div class="m-padded-d-mass">
    <div class="m-container-small m-padded-tb-big">
        <div class="ui container">
            <!--header     th:action="@{/admin/types}"提交数据到/admin/types          th:object="${type}"从后端控制器拿到type对象-->
            <!--th:action="*{id}==null?@{/admin/types}:@{/admin/types/{id}(id = *{id})}"  三则运算表达式  判断id是否有值  然后选择是添加操作还是编辑操作   之后传给Controller              th:action="@{/admin/types}"-->
            <form action="#" method="post" th:object="${type}" th:action="*{id} == null ? @{/admin/types} : @{/admin/types/{id}(id =*{id})}" class="ui form">
                <!--required不输入会变红-->
                <!--隐藏框  存着type里面查出来的id   用于上面正则表达式和后台判断 1111-->
                <input type="hidden" name="id" th:value="*{id}">
                <div class="two fields">
                </div>

                <!--required 不通过变红-->
                <div class="field required">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">名称</label>
                        <!--th:value="*{name}" name从上面th:object="${type}"拿到 1111-->
                        <!--th:value="*{name}" 1111-->
                        <input type="text" name="name" placeholder="分类名称" th:value="*{name}" >
                    </div>
                </div>

                <!--错误信息            th:text="${message}"也可以接收后端传过来的错误信息-->
                <div class="ui error message" >
                </div>


                <!--<div class="ui negative message" th:if="${#fields.hasErrors('name')}">-->
                    <!--<i class="close icon"></i>-->
                    <!--<div class="header">验证失败</div>-->
                    <!--<p th:errors="*{name}">提交信息不符合规则</p>-->
                <!--</div>-->



                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window. history.go(-1)">返回</button>
                    <button class="ui teal button">提交</button>
                </div>

            </form>


        </div>
    </div>


    <br/>
</div>

<!--底部      m-padded-d-mass间隔-->
<footer class="ui segment inverted vertical segment m-padded-d-mass bg">
    <!--container容器 center aligned居中-->
    <div class="ui center aligned container bg">
        <!--grid会把一些布局分为12列  devided加线 -->
        <div class="ui inverted divided grid bg">
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <div class="ui inverted link list bg">
                    <img src="./static/image/wo.jpg" alt="" class="ui rounded image" style="width:110px">

                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list ">
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">联系我吖</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">QQ:822021336</a>
                    <a href="#" class="item">邮箱：xihao.luck@qq.com</a>
                    <a href="#" class="item"></a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-opacity-mini m-text-space m-text-thin m-text-lined">最新博客</h4>
                <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">
                    这是我的个人博客，用于记录我在网上收集的文章，自己的代码笔记，和优秀的文案等等。欢迎大家关注！</p>
            </div>
        </div>
        <div class="ui inverted section divider m-opacity-mini m-text-space m-text-thin m-text-lined "></div>
        <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">Copyright © 2021-2022 会飞的羊 </p>
    </div>

</footer>


<!--jquery-->

<script>
    <!--点击.menu.toggle按钮加入m-mobile-hide样式-->
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide')
    });

    $('.ui.dropdown')
        .dropdown()
    ;
//    非空验证
    $('.ui.form').form({
        fields: {
            //指定name为区域
            name: {
                //identifier:'title',寻找name为title的框
                identifier: 'name',
                rules: [{
                    type: 'empty',
                    prompt: '请输入分类名称'
                }]
            }
        }
    })

</script>

</body>
</html>